﻿myApp.controller("PropertyDirectoryDetailController", function ($scope, $http, $modal, modalService, $routeParams, $location) {
    $scope.share = {};

    function pageInit() {
        var url = 'api/PropertyDirectory/GetPropertyDirectory/' + $routeParams.id;
        $http.get(url).success(function (data) {

            $scope.slides = data.pictureList;
            //dataInherit = data.project;
            //var dataInherit = sessionStorage.getItem($routeParams.id);
            //jsonObj = JSON.parse(dataInherit);
            $scope.Project = data.project;

            if (!$scope.slides) {
                $scope.slides = [];
                $scope.slides.push({ pictureURL: 'http://www.penangrealty.my/images/penang realty,Apartment,house,condominium,terrace house,semi d,detached,bungalow,high end luxury properties,landed properties,gated guarded house.png' });
            }

            $scope.share.url = 'http://www.penangrealty.my/PropertyDirectoryDetail/' + $routeParams.id.toString();
            $scope.share.pictureUrl = $scope.slides ? $scope.slides[0].pictureURL : 'http://www.penangrealty.my/images/penang realty,Apartment,house,condominium,terrace house,semi d,detached,bungalow,high end luxury properties,landed properties,gated guarded house.png';
            $scope.share.title = "[" + $scope.Project.ProjectName + "]" 
            $scope.share.description =  $scope.Project.ProjectLocation
                + '\n' + $scope.Project.ProjectDetails;
            console.log($scope.share.title);
            document.title = "Penang Realty 世界地產 " + $scope.Project.ProjectName;
            console.log(document.title);
            $scope.$emit('newPageLoaded', { 'title': $scope.share.title, 'description': $scope.share.description });

        })

    }
    pageInit();
});